library(tidyverse)
## Warning: package 'dplyr' was built under R version 4.3.2
## Warning: package 'stringr' was built under R version 4.3.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dplyr)
library(stringr)
library(data.table)
##
## Attaching package: 'data.table'
##
## The following objects are masked from 'package:lubridate':
##
## hour, isoweek, mday, minute, month, quarter, second, wday, week,
## yday, year
##
## The following objects are masked from 'package:dplyr':
##
## between, first, last
##
## The following object is masked from 'package:purrr':
##
## transpose
library(mapview)
## Warning: package 'mapview' was built under R version 4.3.2
library(sf)
## Warning: package 'sf' was built under R version 4.3.2
## Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE
library(gt)
library(leaflet)
## Warning: package 'leaflet' was built under R version 4.3.2
url <- "https://tonyfraser-data.s3.amazonaws.com/nyc-addresses/nyc_pluto_23v3_csv/pluto_23v3.csv"
pluto_path <- "./nogit_cache/_pluto_23v3.csv"
if (!file.exists(pluto_path)) {
download.file(url, pluto_path, mode = "wb")
}
pluto <- read_csv(pluto_path)
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
## Rows: 858598 Columns: 92
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (28): borough, schooldist, firecomp, sanitdistrict, sanitsub, address, z...
## dbl (58): block, lot, cd, bct2020, bctcb2020, ct2010, cb2010, council, zipco...
## lgl (6): zonedist3, zonedist4, overlay2, spdist3, dcpedited, notes
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
dfbrklyn<-filter(pluto,borocode=='3', pfirm15_flag=='1')
dfqueens<-filter(pluto,borocode=='4', pfirm15_flag=='1')
dfbronx<-filter(pluto,borocode=='2', pfirm15_flag=='1')
dfmanhattan<-filter(pluto,borocode=='1', pfirm15_flag=='1')
dfstaten<-filter(pluto,borocode=='5', pfirm15_flag=='1')
df_sample_Brooklyn<-sample_n(dfbrklyn,2192)
df_sample_Queens<-sample_n(dfqueens,2155)
df_sample_Bronx<-sample_n(dfbronx,1399)
df_sample_manhattan<-sample_n(dfmanhattan,1283)
df_sample_staten<-sample_n(dfstaten,2040)
df_sample_Brooklyn_flood<- df_sample_Brooklyn %>%
mutate(popup_text= paste("Building Area: ", bldgarea,
"Lot Area: ", lotarea,
"Total Number of Units: ", unitstotal,
"Number of Buildings: ", numbldgs,
"Number of Floors: ", numfloors,
"Assessed Total: ", assesstot,
"Year Built: ", yearbuilt,
"Location: ",address))
df_sample_Queens_flood<- df_sample_Queens %>%
mutate(popup_text= paste("Building Area: ", bldgarea,
"Lot Area: ", lotarea,
"Total Number of Units: ", unitstotal,
"Number of Buildings: ", numbldgs,
"Number of Floors: ", numfloors,
"Assessed Total: ", assesstot,
"Year Built: ", yearbuilt,
"Location: ",address))
df_sample_Bronx_flood<- df_sample_Bronx %>%
mutate(popup_text= paste("Building Area: ", bldgarea,
"Lot Area: ", lotarea,
"Total Number of Units: ", unitstotal,
"Number of Buildings: ", numbldgs,
"Number of Floors: ", numfloors,
"Assessed Total: ", assesstot,
"Year Built: ", yearbuilt,
"Location: ",address))
df_sample_manhattan_flood<- df_sample_manhattan %>%
mutate(popup_text= paste("Building Area: ", bldgarea,
"Lot Area: ", lotarea,
"Total Number of Units: ", unitstotal,
"Number of Buildings: ", numbldgs,
"Number of Floors: ", numfloors,
"Assessed Total: ", assesstot,
"Year Built: ", yearbuilt,
"Location: ",address))
df_sample_staten_flood<- df_sample_staten %>%
mutate(popup_text= paste("Building Area: ", bldgarea,
"Lot Area: ", lotarea,
"Total Number of Units: ", unitstotal,
"Number of Buildings: ", numbldgs,
"Number of Floors: ", numfloors,
"Assessed Total: ", assesstot,
"Year Built: ", yearbuilt,
"Location: ",address))
m_df_sample_staten_flood<-mapview(df_sample_staten_flood,crs = 4269, xcol = "longitude", ycol = "latitude", popup="popup_text", grid = FALSE )
m_df_sample_manhattan_flood<-mapview(df_sample_manhattan_flood,crs = 4269, xcol = "longitude", ycol = "latitude", popup="popup_text", grid = FALSE )
m_df_sample_Bronx_flood<-mapview(df_sample_Bronx_flood,crs = 4269, xcol = "longitude", ycol = "latitude", popup="popup_text",grid = FALSE )
m_df_sample_Queens_flood<-mapview(df_sample_Queens_flood,crs = 4269, xcol = "longitude", ycol = "latitude", popup="popup_text",grid = FALSE )
m_df_sample_Brooklyn_flood<-mapview(df_sample_Brooklyn_flood,crs = 4269, xcol = "longitude", ycol = "latitude",popup="popup_text", grid = FALSE)
m_df_sample_Brooklyn_flood+m_df_sample_Queens_flood+m_df_sample_Bronx_flood+m_df_sample_manhattan_flood+m_df_sample_staten_flood
```